const {
  Reader
} = require("../model/model.js");

const ReaderDao = {
  //保存职位数据
  save(positionInfo) {
    const reader = new Reader(positionInfo);
    return reader.save();
  },
  findByPage(page) {
    const pageSize = 5;
    //返回query对象
    return Reader.find({}).limit(pageSize).skip((page - 1) * pageSize);
  },
  deleteById(id) {
    return Reader.deleteOne({
      _id: id
    });
  },
  updateById(data) {
    return Reader.update({
      _id: data.readerid
    }, {
      readername: data.readername,
      readerbookname: data.readerbookname,
      readerstatus: data.readerstatus
    });
  }
}

module.exports = ReaderDao;
	